package com.zrrd.io.byteStream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author WanJl
 * @version 1.0
 * @title FileInputStreamDemo01
 * @description
 * @create 2023/9/23 18:45
 */
public class FileInputStreamDemo01 {
    public static void main(String[] args) throws Exception {
        //1、创建字节输入流对象FileInputStream
        FileInputStream fileInputStream = new FileInputStream("D:/wanjl.txt");
        //2、调用字节输入流对象中的读取方法read()
            /*int read = fileInputStream.read();
            char c=(char) read;
            System.out.println(c);*/
            /*
                fileInputStream.read()读取数据的方法
                i=fileInputStream.read()，把读取到的数据赋值给i
                i!=-1，就说明后面还有数据要读取，就继续读。
             */
        int i;
        while ((i = fileInputStream.read()) != -1) {
            System.out.println((char) i);
        }
        //3、关闭流，释放资源
        fileInputStream.close();
    }
}
